<?php
namespace osc\api\controller;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/19
 * Time: 14:18
 */

use think\Db;
use think\Request;


class Common extends Base
{

    /**
     * 发送验证码
     * @return array
     */
    public function regsms()
    {
        $data=input('post.');

        try {
            if($data['mobile']==null)
            {
                //throw new \Exception('手机号码不能为空');
                return json_encode(['mage'=>'手机号码不能为空','check'=>0]);
            }

            if($data['mobile']=="")
            {
                //throw new \Exception('手机号码不能为空');
                return json_encode(['mage'=>'手机号码不能为空','check'=>0]);
            }

        } catch (\Exception $e) {

            $this->assign([

                'error' => $e->getMessage(),

            ]);

        }

        //$this->sendsms($data['mobile']);
        $r=osc_service('common','Member')->api_sendsms_common($data['mobile'],'regsms');

        return json_encode($r);


    }


    /**
     * 交易所信息接口
     * @return string
     */
    public function index(){

        if($this->request->isPost()){
            $postData = $this->request->post('data');
            if(!$postData){
                return json_encode(['check'=>0, 'mage'=>'提交错误!']);
            }

            $data = encode($postData);

            return json_encode(['check'=>1, 'mage'=>'OK', 'data'=>$data]);
        }else{
            return json_encode(['check'=>0, 'mage'=>'提交错误!']);
        }
    }

}